package com.milk.milkpush.springboot;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 测试controller
 *
 * @author wh
 * @date 2023/12/15 14:12
 */
@RestController
@RequestMapping("/mqtt")
public class MqttController {

    @Resource
    private MqttSendClient mqttSendClient;

    @GetMapping(value = "/publishTopic")
    public String publishTopic(String topic, String sendMessage) {
        System.out.println("topic:" + topic);
        System.out.println("message:" + sendMessage);
        this.mqttSendClient.publish(true, topic, sendMessage);
        return "topic:" + topic + "\nmessage:" + sendMessage;
    }

}
